Repository navigation
Conversation
Register the file log appender after QApplication creation and setApplicationName so the log path uses a valid application name. 将文件日志 appender 的注册移动到设置应用名之后,避免应用名为空时 DTK 将路径计算为 ~/.cache/.log;同时移除会缓存错误路径的早期 getlogFilePath 调用。 Log: 修复运行日志写入错误路径的问题 Influence: 运行日志恢复到 ~/.cache/deepin/deepin-camera/deepin-camera.log,启动早期日志仍输出到控制台。
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Resurgamz The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideUses of the APIKeep console logging registered early, but register the file appender and print its path only after the organization and application names are set.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/main.cpp" line_range="334" />
<code_context>
+ // 控制台日志尽早注册,确保启动阶段日志不遗漏
//qputenv("QT_LOGGING_RULES", "*.debug=true;*.info=true");
DLogManager::registerConsoleAppender();
- DLogManager::registerFileAppender();
- qInfo() << "LogFile:" << DLogManager::getlogFilePath();
+ // 文件日志路径依赖 organizationName/applicationName,必须在设置应用名后再注册
</code_context>
<issue_to_address>
**Startup diagnostics disappear from log**
When startup diagnostics are emitted before the file appender is registered, earlier `qInfo()`, `qWarning()`, and `qDebug()` calls run before `DLogManager::registerFileAppender()`, so they reach only the console and are not replayed to the file; inspecting the persistent log therefore omits startup diagnostics.
Register the file appender after the application name is set but before emitting startup diagnostics.
</issue_to_address>| qApp->setApplicationName("deepin-camera"); | ||
| // 文件日志依赖 organizationName/applicationName 计算路径, | ||
| // 必须在应用名设置完成后再注册,否则会写到 ~/.cache/.log | ||
| DLogManager::registerFileAppender(); |
There was a problem hiding this comment.
🟡 Medium · Startup diagnostics disappear from log
When startup diagnostics are emitted before the file appender is registered, earlier qInfo(), qWarning(), and qDebug() calls run before DLogManager::registerFileAppender(), so they reach only the console and are not replayed to the file; inspecting the persistent log therefore omits startup diagnostics.
Register the file appender after the application name is set but before emitting startup diagnostics.
Prompt for AI agents
In `src/main.cpp` at line 334:
**Startup diagnostics disappear from log**
When startup diagnostics are emitted before the file appender is registered, earlier `qInfo()`, `qWarning()`, and `qDebug()` calls run before `DLogManager::registerFileAppender()`, so they reach only the console and are not replayed to the file; inspecting the persistent log therefore omits startup diagnostics.
Register the file appender after the application name is set but before emitting startup diagnostics.
问题
正式包(release/eagle 线,6.0.13)运行日志未写入预期路径
~/.cache/deepin/deepin-camera/deepin-camera.log,而是写到了~/.cache/.log,排查问题时找不到对应日志。根因
提交 d2d696e 将
DLogManager::registerFileAppender()提前到main()开头。此时QApplication尚未创建,organizationName()/applicationName()均为空,DTK 按$XDG_CACHE_HOME/<org>/<app>/<app>.log计算得到~/.cache/.log。此外早期调用的getlogFilePath()会把错误路径缓存到m_logPath。修改
registerConsoleAppender()提前注册,启动早期日志仍输出到控制台;registerFileAppender()与LogFile打印移动到setOrganizationName()/setApplicationName()之后;getlogFilePath()调用。验证
~/.cache/deepin/deepin-camera/deepin-camera.log,LogFile:打印正确路径;~/.cache/.log不再新增内容;XDG_CACHE_HOME下目录可自动创建。备注
该问题为 d2d696e 引入的回归,仅影响 release/eagle 线;master 已采用新的日志系统,不存在此问题。
Summary by Sourcery
Bug Fixes:
~/.cache/.logpath.